package service

import (
	"context"
	"errors"
	__ "hospital-srv/basic/proto"
	"hospital-srv/handler/dao"
)

// // Deepseek ai提问
func (s *Serve) DeepSeekGetAnswer(_ context.Context, in *__.DeepSeekGetAnswerReq) (*__.DeepSeekGetAnswerResp, error) {
	//ai提问与回复
	res, err := dao.HandleAiResp(in.Question)
	if err != nil {
		return nil, errors.New("回复失败" + err.Error())
	}

	err = dao.SetQuestion(in.UserId, in.RoomId, in.Question, res)
	if err != nil {
		return nil, errors.New(err.Error())
	}
	return &__.DeepSeekGetAnswerResp{
		Answer: res,
	}, nil
}

// 提问历史
func (s *Serve) DeepSeekHistory(_ context.Context, in *__.DeepSeekHistoryReq) (*__.DeepSeekHistoryResp, error) {
	problemList, err := dao.QuestionList(in.UserId, in.RoomId)
	if err != nil {
		return nil, errors.New(err.Error())
	}
	return &__.DeepSeekHistoryResp{List: problemList}, nil
}
